package com.sjz.myfrist;


import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

/***
 *   Activity 之间传送数据
 */
public class ActReceiveResultActivity extends AppCompatActivity implements View.OnClickListener {
    private static final String mresponse = "over  receive info";



    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.act_receive_result);
        TextView tv_request = findViewById(R.id.actreceive_result_tv_request);
        Bundle bundle = getIntent().getExtras();
        String request_content = bundle.getString("request_content");
        String desc = String.format("收到请求：%s",request_content);//得到acitivity 跳转传过来的值
        tv_request.setText(desc);//得到传递过来的值
        findViewById(R.id.actreceive_result_btn_response).setOnClickListener(this);
        TextView tv_response = findViewById(R.id.actreceive_result_tv_response);
        tv_response.setText("待返回消息："+mresponse);

    }

    @Override
    public void onClick(View view) {
        Intent intent = new Intent();
        Bundle bundle = new Bundle();
        bundle.putString("response_content",mresponse);
        intent.putExtras(bundle);
        //携带意图返回上一页面，RESULT_OK表示处理成功
        setResult(Activity.RESULT_OK,intent);
        //结束页面
        finish();
    }

}